//
//  Runtime_demoVc.m
//  Project_Demo
//
//  Created by Leon on 2018/7/1.
//  Copyright © 2018年 caoxiaozhu. All rights reserved.
//

#import "Runtime_demoVc.h"

@interface Runtime_demoVc ()

@end

@implementation Runtime_demoVc


-(void)runTime{
    NSLog(@"没有暴露方法也能运行!");
}

//添加方法
+(BOOL)resolveInstanceMethod:(SEL)sel{
    NSLog(@"%@",NSStringFromSelector(sel));
    //不带属性的方法
    if (sel == NSSelectorFromString(@"add")) {
        class_addMethod(self, sel, (IMP)add, "v@:");
        return YES;
    }else if(sel == NSSelectorFromString(@"addCharacter:")){
        class_addMethod(self, sel, (IMP)addCharacter, "v@:@");
        return YES;
    }
    return [super resolveInstanceMethod:sel];
}

void add(id self,SEL _cmd){
    NSLog(@"添加了方法");
}

void addCharacter(id self, SEL _cmd, NSString*nameStr){
    NSLog(@"添加了%@方法",nameStr);
}

@end
